<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="法人标识" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bankNoCd">
              <a-input v-model="model.bankNoCd" placeholder="请输入法人标识"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="权限划分类别。按固定依据划分数据权限：1-角色2-机构3-用户" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="devideCls">
              <a-input v-model="model.devideCls" placeholder="请输入权限划分类别。按固定依据划分数据权限：1-角色2-机构3-用户"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="分支机构编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bankCode">
              <a-input v-model="model.bankCode" placeholder="请输入分支机构编码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="报表id" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="reportId">
              <a-input v-model="model.reportId" placeholder="请输入报表id"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="数据状态。1-未生成2-已生成有误3-已生成成功" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dataStatus">
              <a-input v-model="model.dataStatus" placeholder="请输入数据状态。1-未生成2-已生成有误3-已生成成功"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="校验状态。1-未校验2-已校验有误3-已校验无误" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="verifyStatus">
              <a-input v-model="model.verifyStatus" placeholder="请输入校验状态。1-未校验2-已校验有误3-已校验无误"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="数据日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sjrq">
              <j-date placeholder="请选择数据日期" v-model="model.sjrq"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="是否强制提交:0-否,1-是" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ifCommit">
              <a-input v-model="model.ifCommit" placeholder="请输入是否强制提交:0-否,1-是"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="是否强制校验:0-否,1-是" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ifVerify">
              <a-input v-model="model.ifVerify" placeholder="请输入是否强制校验:0-否,1-是"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="上一日提交人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lastdayPerson">
              <a-input v-model="model.lastdayPerson" placeholder="请输入上一日提交人"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="角色id" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="roleId">
              <a-input v-model="model.roleId" placeholder="请输入角色id"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="是否可生成，0-否，1-是" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="createFlag">
              <a-input v-model="model.createFlag" placeholder="请输入是否可生成，0-否，1-是"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="是否可校验，0-否，1-是" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="verifyFlag">
              <a-input v-model="model.verifyFlag" placeholder="请输入是否可校验，0-否，1-是"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="主题" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="theme">
              <a-input v-model="model.theme" placeholder="请输入主题"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="锁库状态，0-未锁库，1-已锁库，2-已锁库（强制锁库）,3-已解锁" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lockFlag">
              <a-input v-model="model.lockFlag" placeholder="请输入锁库状态，0-未锁库，1-已锁库，2-已锁库（强制锁库）,3-已解锁"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'LlbbMessageStatusForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/reportManagement.llbbMessageStatus/llbbMessageStatus/add",
          edit: "/reportManagement.llbbMessageStatus/llbbMessageStatus/edit",
          queryById: "/reportManagement.llbbMessageStatus/llbbMessageStatus/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }

        })
      },
    }
  }
</script>